
import java.util.Observable;

import android.media.MediaPlayer;



public class StoryTimer extends Observable implements Runnable{
	
    private int remainingTime = 0;
    
    private static StoryTimer inst = new StoryTimer();

	private StoryTimer(){}
	
	public static StoryTimer getInstance(){
		return inst;
	}

    public StoryTimer(int trackDuration){
        this.remainingTime = trackDuration;
    }	
 

    public void startTicking() 
    { 
        System.out.println("Starting.");        
        new Thread(this).start(); 
    }


    public void run(){
            try{
                while(this.remainingTime>=0){
                    this.setChanged();
                    this.notifyObservers("The Remaining Time is updated");
                    //sleep for 1 second
                    Thread.sleep(3000);                
                    //decrement timer time by 1 second
                    this.remainingTime = this.remainingTime - 1;              
                }//while

            }//try
            catch (InterruptedException e) {
                e.printStackTrace();
            }//catch

        }//run
 
    
    public void stopTimer()
    {
     //ToDo
    }
    
    public void pauseTimer(int duration)
    {
     //ToDo
    }
    
    public int getRemTime() {
        return remainingTime;
    }//getRemTime 

    public void setRemTime(int remTime) {
        this.remainingTime = remTime;
    }//setRemTime 


	

}


